package com.bwhx.eruler.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.bwhx.eruler.bean.Page;
import com.bwhx.eruler.bean.RulerSdkData;
import com.bwhx.eruler.service.RulerSdkDataService;
/**
 * @author Cuilitang
 *
 */

@Controller
public class RulerSdkDataController extends BaseController {
	
	@Autowired
	RulerSdkDataService rulerSdkDataService;
	
	@ResponseBody
	@RequestMapping(value = "/page.rsdList.ashx")
	 public Map<String,Object> rsdList(Integer page,Integer rows,RulerSdkData rsd) {
		//每页的开始记录
        int start = (page-1)*rows;
        Page p = new Page(start,rows,rsd);
		Map<String,Object> map = new HashMap<String,Object>();
		
		try{
			List<RulerSdkData> list = rulerSdkDataService.list(p);
			Integer count = rulerSdkDataService.count(rsd);
			
			map.put("total",count );//total键 存放总记录数，必须的  
			map.put("rows",list);//rows键 存放每页记录 list 
			
		}catch(Exception e){
			log.error(getTrace(e));
			map.put("meg", "失败！");
			map.put("status", "0");
		}
		
	    return map;  
	}
	
	
	

	@RequestMapping(value = "/page.sdksdata.ashx")
	 public ModelAndView sdksdata(HttpServletRequest request) {
		String sdkId = request.getParameter("sdkId");
		ModelAndView mav = new ModelAndView("/buyersdk/buyersdkdatalist.jsp");
		if(null!=sdkId&&!sdkId.equals("")){
			mav.addObject("sdkId", sdkId);
		}
	    return mav;  
	}

	
	

	

}
